<?php

namespace app\admin\controller\health\user;

use app\common\controller\Backend;
use app\health\model\HealthUserServeRecord;

class UserServeRecord extends Backend
{
    public function index()
    {
        if ($this->request->isAjax()) {
            $params     = $this->request->param();
            $limit      = $params['limit'] ?? 10;
            $userMobile = $params['user_mobile'] ?? '';
            $where      = [];
            if (!empty($userMobile)) {
                $where['user_mobile'] = ['like', "%{$userMobile}%"];
            }
            $paginate      = HealthUserServeRecord::where($where)
                ->with(['user'])
                ->order('id', 'desc')
                ->paginate($limit);
            $data['rows']  = $paginate->items();
            $data['total'] = $paginate->total();
            $this->success('', null, $data);
        }
        $this->assign('title', '服务使用记录');
        return $this->fetch();
    }
}